from controllers.Base import HttpController
import json
from settings import PROJECT_NAME, PROJECT_VERSION, PROJECT_START_TIMESTAMP, g_settings


class WebIndexController(HttpController):
    async def get(self, *args, **kwargs):
        data = await self.do()
        # self.write(data)

        # print(data)


        await self.render("index.html",
                          PROJECT_NAME=PROJECT_NAME,
                          PROJECT_VERSION=PROJECT_VERSION,
                          )

    async def do(self):
        request_params = self.request_get_params()

        res = {
            "project_name": PROJECT_NAME,
            "project_version": PROJECT_VERSION,
            "project_start_timestamp": PROJECT_START_TIMESTAMP,
            "settings": g_settings.getStr()
        }

        return json.dumps(res)
        # return json.dumps(data, cls=ComplexEncoder)

